package com.maomao.fastjson;

import com.alibaba.fastjson.JSON;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by admin on 2018/5/24.
 */
public class StringToMap {
    public static void main(String[] args) {
        map2JSON();
    }
    public static void map2JSON() {
        Map map = new HashMap();
        map.put(1, 2);
        map.put(3, 4);
        map.put(5, 6);
        String json = JSON.toJSONString(map);
        System.out.println(json);
        Map map1 = JSON.parseObject(json);
        Map<Integer, Integer> useMap= new HashMap<>(map1);
        Integer a = useMap.get(1);
        if (a!=null) {
            System.out.println(a);
        }
//        useMap = map1;
        for (Map.Entry entry:useMap.entrySet()){

            System.out.println(entry.getKey() + "--->" + entry.getValue());
        }

    }
}
